This repository was archived by the owner on Nov 11, 2022. It is now read-only.
Make classloader handling more compatible with JDK 9#621
Open
cushon wants to merge 1 commit intoGoogleCloudPlatform:master-1.xfrom
Open
Make classloader handling more compatible with JDK 9#621cushon wants to merge 1 commit intoGoogleCloudPlatform:master-1.xfrom
cushon wants to merge 1 commit intoGoogleCloudPlatform:master-1.xfrom
Conversation
tgroh
reviewed
Jan 26, 2018
| } | ||
| if (!(classLoader instanceof URLClassLoader)) { | ||
| String message = String.format("Unable to use ClassLoader to detect classpath elements. " | ||
| + "Current ClassLoader is %s, only URLClassLoaders are supported.", classLoader); |
Contributor
There was a problem hiding this comment.
This error message should be updated.
| protected static List<String> detectClassPathResourcesToStage(ClassLoader classLoader) { | ||
| if (classLoader == ClassLoader.getSystemClassLoader()) { | ||
| return Splitter.on(File.pathSeparatorChar) | ||
| .splitToList(StandardSystemProperty.JAVA_CLASS_PATH.value()); |
Contributor
There was a problem hiding this comment.
My understanding is that the contents of the classpath are permitted to be relative paths, including directories, and the ClassLoader will search within each directory and JAR it finds on the classpath; so this may not return the absolute paths to all of the resources in all cases.
Contributor
Author
There was a problem hiding this comment.
Thanks, it now makes the paths absolute.
Note that if the classpath contains directories URLClassLoader.getURLs will return the URLs of those directories, so this doesn't change how directories are handled.
From http://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html: The application class loader is no longer an instance of java.net.URLClassLoader (an implementation detail that was never specified in previous releases). Code that assumes that ClassLoader::getSytemClassLoader returns a URLClassLoader object will need to be updated. Note that Java SE and the JDK do not provide an API for applications or libraries to dynamically augment the class path at run-time.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From
http://www.oracle.com/technetwork/java/javase/9-relnote-issues-3704069.html: